package com.novel.entiy.dto;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.novel.entiy.Chapter;
import com.novel.utils.BeanConverter;
import com.novel.utils.ConverterUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;

/**
 * @author chihuo
 * @date 2022/4/5
 */
@ApiModel(value = "章节")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ChapterDTO implements BeanConverter<Chapter>, Serializable {
    @ApiModelProperty(value = "")
    private Long id;

    /**
     * 文章id
     */
    @NotNull(message = "参数有误")
    @ApiModelProperty(value = "文章id")
    private Long novelId;

    /**
     * 章节名称
     */
    @NotBlank(message = "章节名称不能为空")
    @ApiModelProperty(value = "章节名称")
    private String chapterName;

    /**
     * 章节号
     */
    @ApiModelProperty(value = "章节号")
    private Integer chapterNo;

    /**
     * 章节字数
     */
    @ApiModelProperty(value = "章节字数")
    private Long wordNums;

    /**
     * 章节内容-markdown
     */
    @ApiModelProperty(value = "章节内容-markdown")
    private String chapterContentMarkdown;

    /**
     * 0:草稿 1:发布
     */
    @ApiModelProperty(value = "0:草稿 1:发布")
    private Integer status;

    /**
     * 转换接口方法
     *
     * @return T
     */
    @Override
    public Chapter doForward() {
        Chapter chapter = new Chapter();
        ConverterUtil.copyPropertiesIgnoreNull(this, chapter);
        return chapter;
    }
}